package kpi.java_training.testing.services;


import com.sun.deploy.util.StringUtils;

import java.util.List;

/**
 * Class implements utils associated with strings
 */
public class StringServices {

    /**
     *  Method unites two strings into one string. Strings are divided by "\n"
     */
    static public String makeString(String string1, String string2) {
        return String.format("%s\n%s", string1, string2);
    }

    static public String[] getWords(String string) {
        return StringUtils.splitString(string, " ");
    }

    static public String getSaveDataFromStrings(List<String> strings) {
        int length = strings.size();
        String resultStr = Integer.toString(length);
        for (int i = 0; i < length; i++) {
            resultStr = makeString(resultStr, strings.get(i));
        }
        return resultStr;
    }

    static public String getSaveDataFromIntegers(List<Integer> numbers) {
        String resultStr = Integer.toString(numbers.size());
        for (Integer i : numbers) {
            resultStr = makeString(resultStr, i.toString());
        }
        return resultStr;
    }
}
